package com.tanhua.back.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.back.entity.AnalysisByDay;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {


    /**
     * 最近几天活跃用户
     *
     * @return
     */
    @Select("SELECT SUM(${clume}) " +
            "FROM " +
            "tb_analysis_by_day " +
            "WHERE " +
            "record_date > #{proDate} and record_date < #{dateTime}")
    Long queryActiveUserCount(String clume, String dateTime, String proDate);

    /*
    获取全部用户
     */
    @Select("SELECT SUM(num_registered) FROM `tb_analysis_by_day` ")
    Long cumulativeUsers();

    /**
     * 计算单日单个列的数据
     *
     * @param dateTime
     * @param clume
     * @return
     */
    @Select("SELECT ${clume} FROM " +
            "`tb_analysis_by_day` " +
            "where record_date = #{dateTime}")
    Long getCout(String dateTime, String clume);
}
